Highcharts.setOptions({
	global : {
		useUTC : false
	}
});
function activeLastPointToolip(chart) {
	var points = chart.series[0].points;
	chart.tooltip.refresh(points[points.length - 1]);
}
function pageName() {
	var a = location.href;
	var b = a.split("/");
	var c = b.slice(b.length - 1, b.length).toString(String).split(".");
	console.info(a)
	console.info(b)
	console.info(c)
}
var ia;
function cleara() {
	console.info("cleara")
	window.clearInterval(ia);
}
var ib;
function offerObj() {
	ib = window.setInterval(function() {
		$.ajax({
			url : "/QueueTest01/queueController?type=offerObj",
			type : "POST",
			async : false,
			dataType : "jsonp",
			jsonp : "jsonpcallback",
			success : function(msg) {
				if (msg.result) {

				}
			},
			error : function(errMsg) {
				alert('error');
			}
		});
	}, 500);
}
function clearb() {
	console.info("clearb")
	window.clearInterval(ib);
}
function getQueueSize() {
	var res = 0;
	$.ajax({
		url : "/QueueTest01/queueController?type=getQueueSize",
		type : "POST",
		async : false,
		dataType : "jsonp",
		jsonp : "jsonpcallback",
		success : function(msg) {
			if (msg.result) {
				console.info(msg.info)
				res = msg.info;
			}
		},
		error : function(errMsg) {
			alert('error');
		}
	});
	return res;
}
var chart = Highcharts.chart('container', {
	chart : {
		type : 'spline',
		marginRight : 10,
		events : {
			load : function() {
				var series = this.series[0], chart = this;
				activeLastPointToolip(chart);
				ia = window.setInterval(function() {
					var x = (new Date()).getTime(), // 当前时间
					// y = Math.random(); // 随机值
					y = getQueueSize(); // 随机值
					series.addPoint([ x, y ], true, true);
					activeLastPointToolip(chart);
				}, 1000);
			}
		}
	},
	title : {
		text : '动态模拟实时数据'
	},
	xAxis : {
		type : 'datetime',
		tickPixelInterval : 150
	},
	yAxis : {
		title : {
			text : null
		}
	},
	tooltip : {
		formatter : function() {
			return '<b>' + this.series.name + '</b><br/>'
					+ Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x)
					+ '<br/>' + Highcharts.numberFormat(this.y, 2);
		}
	},
	legend : {
		enabled : false
	},
	series : [ {
		name : '随机数据',
		data : (function() {
			// 生成随机值
			var data = [], time = (new Date()).getTime(), i;
			for (i = -19; i <= 0; i += 1) {
				data.push({
					x : time + i * 1000,
					y : 0
				});
			}
			return data;
		}())
	} ]
});
var ic;
function test() {
	ic = window.setInterval(function() {
		console.info(Math.random())
		console.info(getQueueSize())
	}, 500);
}
function clearTest() {
	console.info("clearTest")
	window.clearInterval(ic);
}